<template>
  <div class="rule-set">
    <el-form label-position="right" label-width="275px" :disabled="emitData.isDisabled">
      <el-form-item label="评价过程比例控制：">
        <el-switch
          v-model="emitData.switchLink2"
          active-value="1"
          inactive-value="0"
          :disabled="type === 'view'"></el-switch>
        <span class="tip" v-if="emitData.switchLink2 === '1'">
          (拟等次为“好”比例占参评人员比例的
          <el-input
            size="small"
            class="simple"
            v-model="emitData.countRule5"
            @input="filterNonNumeric('5')"
            :disabled="type === 'view'"></el-input>
          %)
        </span>
      </el-form-item>
      <!-- <el-form-item label="单位管理员是否自动确认考核：">
        <el-switch v-model="emitData.switchLink1" active-value="1" inactive-value="0"></el-switch>
      </el-form-item> -->
      <el-form-item label="考核等次结果：">
        <el-radio-group v-model="emitData.radioLink" :disabled="type === 'view'">
          <el-radio label="0">不带入</el-radio>
          <el-radio label="1">带入一级结果</el-radio>
          <el-radio label="2">带入二级结果</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item>
        <div class="form-tips">
          注：一级结果为部门负责人或分管负责人评价结果，二级结果为分管负责人或主要负责人评价结果。
        </div>
      </el-form-item>
      <el-form-item label="等次比例确认控制：">
        拟等次为“好”比例占参评人员比例的
        <el-input
          size="small"
          class="simple"
          v-model="emitData.countRule6"
          @input="filterNonNumeric('6')"
          :disabled="type === 'view'"></el-input>
        %
      </el-form-item>
      <el-form-item label="考核结果等次确认是否提醒：">
        <!-- <el-radio-group v-model="emitData.radioLink1">
          <el-radio label="0">手动确认</el-radio>
          <el-radio label="2">提醒确认</el-radio>
        </el-radio-group> -->
        <el-switch
          v-model="emitData.radioLink1"
          active-value="2"
          inactive-value="0"
          :disabled="type === 'view'"></el-switch>
      </el-form-item>
      <el-form-item>
        <div class="form-tips">注：使用此功能可发送提示信息至单位主要负责人，对其催办等次结果确认。</div>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'RuleSet',
  components: {},
  props: {
    formData: {
      type: Object,
      default: () => {
        return {
          switchLink1: '1',
          radioLink: '',
          radioLink1: '',
          switchLink2: '1',
          countRule5: '',
          countRule6: '',
        }
      },
    },
  },
  data() {
    return {
      emitData: {
        switchLink1: '1',
        radioLink: '',
        radioLink1: '',
        switchLink2: '1',
        countRule5: '',
        countRule6: '',
      },
      type: '',
    }
  },
  watch: {
    formData: {
      handler(news) {
        this.emitData = Object.assign(this.emitData, news)
      },
      immediate: true,
      deep: true,
    },
  },
  computed: {},
  created() {},
  mounted() {
    this.type = this.$route.query.type || ''
  },
  methods: {
    toEmit(id) {
      const param = {
        ...this.emitData,
        step: id || '',
      }
      this.$emit('reviewData', param)
    },
    filterNonNumeric(num) {
      const str = 'countRule' + num
      // 限制输入数字 最大值 100 最小值0
      this.emitData[str] = this.emitData[str].replace(/\D/g, '')
      if (Number(this.emitData[str]) > 100) {
        this.emitData[str] = 100
      }
      if (Number(this.emitData[str]) < 0) {
        this.emitData[str] = 0
      }
    },
  },
}
</script>
<style lang="scss" scoped>
.rule-set {
  width: 100%;
  height: 100%;
  .tip {
    color: #999999;
    margin-left: 10px;
  }
  .simple {
    width: 50px;
  }
  .form-tips {
    color: #d9001b;
  }
}
</style>
